import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hitutor/Util/MyColor.dart';
import 'package:hitutor/Util/PageUtil.dart';

import 'MyImage.dart';

class MyPage extends StatelessWidget {
  MyPage(this.title, this.body, {this.onLeftTap, this.haveBack, this.rightWidgets, this.bgColor, this.resizeToAvoidBottomInset});

  String title = "";
  void Function()? onLeftTap;
  bool? haveBack = true;
  List<Widget>? rightWidgets;
  Widget body;
  Color? bgColor;
  bool? resizeToAvoidBottomInset;

  @override
  Widget build(BuildContext context) {
    haveBack = haveBack ?? true;
    return Scaffold(
        //鍵盤彈出後是否改變屏幕大小
        resizeToAvoidBottomInset: resizeToAvoidBottomInset ?? true,
        backgroundColor: bgColor ?? MyColor.White,
        appBar: AppBar(toolbarHeight: 0, systemOverlayStyle: SystemUiOverlayStyle.dark, backgroundColor: MyColor.Transfer, elevation: 0),
        body: Column(children: [
          Container(
              height: 40,
              child: AppBar(
                backgroundColor: MyColor.Transfer,
                toolbarHeight: 40,
                title: Title(
                    child: Text(title, style: TextStyle(fontSize: 17.0, color: Color(0xFF252427), fontWeight: FontWeight.bold)),
                    color: MyColor.Black),
                centerTitle: true,
                elevation: 0,
                leading: Builder(builder: (BuildContext context) {
                  return haveBack!
                      ? LocalImage("left.png",
                          padding: EdgeInsets.all(10),
                          width: 15,
                          height: 15,
                          onTap: onLeftTap ??
                              () {
                                PageUtil().back(context);
                              })
                      : Container();
                }),
                actions: rightWidgets,
              )),
          Container(height: 0.5, color: MyColor.DD),
          Expanded(child: body)
        ]));
  }
}
